package com.sealer.pattern.structural.flyweight;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * Created by sealer on 17/04/04.
 */
public class Menu {
    private Map<String, CoffeeFlavor> flavors = new ConcurrentHashMap<String, CoffeeFlavor>();

    synchronized CoffeeFlavor lookup(final String flavorName) {
        if (!flavors.containsKey(flavorName))
            flavors.put(flavorName, new CoffeeFlavor(flavorName));
        return flavors.get(flavorName);
    }

    synchronized int totalCoffeeFlavoursMade() {
        return flavors.size();
    }
}
